<template>
	<el-container>
		<el-header style="height: auto;">
			<sc-select-filter :data="filterData" :label-width="80" @on-change="filterChange"></sc-select-filter>
		</el-header>
		<el-header>
			<div class="left-panel">
			</div>
			<div class="left-panel"> </div>
			<div class="right-panel">
				<el-form-item label="申请人" style="padding-top: 20px;">
					<select-user-dialog v-model:accountId="search.accountId" :mode="false"/>
				</el-form-item>
				<div class="right-panel-search">
					<el-input v-model="search.keyword" placeholder="标题" clearable></el-input>
					<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
				</div>
			</div>
		</el-header>
		<el-main class="nopadding">
			<scTable ref="table" :apiObj="apiObj" row-key="applyId" stripe remoteSort remoteFilter>
				<el-table-column label="#" type="index" width="50"></el-table-column>
				<el-table-column label="申请标题" prop="title" width="200" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column label="物资名称" prop="suppliesName" width="150"></el-table-column>
				<el-table-column label="品牌" prop="brand" width="100"></el-table-column>
				<el-table-column label="规格型号" prop="model" width="150"></el-table-column>
				<el-table-column label="申请数量" prop="quantity" width="150">
					<template #default="scope">
						{{scope.row.quantity}}/{{scope.row.unitName}}
					</template>
				</el-table-column>
				<el-table-column label="审批数量" prop="approvalQuantity" width="150">
					<template #default="scope">
						{{scope.row.approvalQuantity}}/{{scope.row.unitName}}
					</template>
				</el-table-column>
				<el-table-column label="已发放" prop="zs" width="100">
					<template #default="scope">
						{{scope.row.zs}}/{{scope.row.unitName}}
					</template>
				</el-table-column>
				<el-table-column label="备注" prop="remark" width="300" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column label="操作" fixed="right" align="right" width="100">
					<template #default="scope">
						<el-button-group>
							<el-button text type="primary" size="small" @click="doGranTo(scope.row, scope.$index)">发放</el-button>
						</el-button-group>
					</template>
				</el-table-column>
			</scTable>
		</el-main>
	</el-container>
	<granto-dialog v-if="dialog.save" ref="saveDialog" @success="handleSuccess" @closed="dialog.save=false"></granto-dialog>
</template>

<script>
import selectUserDialog from "@/views/module/selectUserDialog";
import scSelectFilter from '@/components/scSelectFilter'
import GrantoDialog from "@/views/office/supplies/granto/grantoDialog";
export default {
	name: 'Office Supplies Gran To',
	components: {
		GrantoDialog,
		scSelectFilter,
		selectUserDialog
	},
	data() {
		return {
			dialog: {
				save: false,
			},
			filterData: [
				{
					title: "日期范围",
					key: "date",
					multiple: false,
					options: [
						{
							label: "全部",
							value: ""
						},
						{
							label: "今日",
							value: "1"
						},
						{
							label: "昨日",
							value: "2"
						},
						{
							label: "一周内",
							value: "3"
						},
						{
							label: "一月内",
							value: "4"
						},
						{
							label: "一月前",
							value: "5"
						}
					]
				}
			],
			apiObj: this.$API.office.officeSupplies.getGrantOfficeSuppliesList,
			search: {
				date:'',
				keyword: null,
				accountId:''
			}
		}
	},
	mounted() {
	},
	methods: {
		filterChange(data){
			this.search.date = data.date;
			this.$refs.table.upData(this.search)
		},
		doGranTo(row,index)
		{
			this.dialog.save = true
			this.$nextTick(() => {
				this.$refs.saveDialog.open().setData(row)
			})
		},
		//搜索
		async upsearch() {
			this.$refs.table.upData(this.search)
		},
		handleSuccess(data, mode) {
			this.$refs.table.refresh();

		},
	}
}
</script>

<style>
</style>
